﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ISRecord.View.ViewsModel;
using ISRecord.Model;
using System.Collections.ObjectModel;

namespace ISRecord.View.Views
{
    /// <summary>
    /// Interaction logic for SearchOutboxView.xaml
    /// </summary>
    public partial class SearchOutboxView : Window
    {
        SearchOutboxViewModel vm;
        public SearchOutboxView():this(null)
        {
            
            
        }
        public SearchOutboxView(SearchOutboxViewModel vm)
        {
            InitializeComponent();
            
            this.vm = vm;
            if (this.vm == null)
            {
                this.vm = new SearchOutboxViewModel(
                    new ObservableCollection<Outbox>(SearchOutboxViewModel.GetAll()));
            }
            base.DataContext = this.vm;
            
        }

        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            OkResult();
        }
        private void SelectedItemDoubleClick(object sender, MouseButtonEventArgs e)
        {
            OkResult();
        }
        private void OkResult()
        {
            this.DialogResult = true;
            vm.Cleanup();

            Close();
        }
        
    }
}
